<template>
	<view>
		<z-paging :show-refresher-when-reload="true"  show-refresher-update-time  ref="paging" v-model="dataList" @query="queryList">
			<!-- z-paging默认铺满全屏，此时页面所有view都应放在z-paging标签内，否则会被盖住 -->
			<!-- 需要固定在页面顶部的view请通过slot="top"插入，包括自定义的导航栏 -->
			
			<view slot="top" class="" >
				<back title="地址管理"></back>
				<view class="search_box" >
					<view class="search_box_right">
						<view class="search_input_icon">
							<u-icon name="search" color="#333" size="28"></u-icon>
						</view>
						<input class="search_input" @confirm="search_submit"  v-model="name" type="text" placeholder-class="search" placeholder="请输入搜索内容" />
						<view  @click="search_submit" class="search_btn">
							搜索
						</view>
					</view>
				</view>
			</view>
			<view class="addresList" >
				<view v-for="(item,index) in dataList" :key="index"class="addresList_item">
					<!-- <view class="addresList_item_user_item">
						<view class="">
							收货信息:{{item.name}}
						</view>
						<view class="">
							<span @click="del(item.id)">【删除】</span>
							<span @click="navTo('/pages/addAddresss/addAddresss?id='+item.id)">【修改】</span>
						</view>
					</view>
					<view class="addresList_item_user_item">
						<view class="">
							手机号码:{{item.phone}}
						</view>
					</view>
					<view class="addresList_item_user_item">
						<view class="">
							详细地址:{{item.province}} {{item.city}} {{item.area}} {{item.address}}
						</view>
						<view class="">
								<u-icon name="checkmark-circle-fill" color="#09bb07" size="32"></u-icon>
						</view>
					</view> -->
					<view class="">
						<view class="address_text1">
							{{item.province}} {{item.city}} {{item.area}}
						</view>
						<view class="address_text2">
							{{item.province}} {{item.city}} {{item.area}}
						</view>
						<view class="address_text3">
							{{item.name}} &nbsp; {{item.phone}}
							<!-- <span class="moren">默认</span> -->
						</view>
					</view>
					<image @click="navTo('/pages/addAddresss/addAddresss?id='+item.id)" src="../../static/vip/icon_48.png" style="width: 30rpx; height: 30rpx;" mode=""></image>
				</view>
			</view>
			<view slot="bottom" class="">
				<view  class="button_submit_all1">
					<u-button @click="navTo('/pages/addAddresss/addAddresss')"  class="btns_all"  :hair-line="false" :ripple="true" ripple-bg-color="rgba(9, 82, 200, 0.15)">
						+添加收货地址
					</u-button>
				</view>
			</view>
		</z-paging>
	</view>
</template>

 <script>
	 import back from '@/componts/back.vue';
	export default {
		components:{
			back
		},
		data() {
			return {
				style:{},
				title:'地址管理',
				name:'',
				dataList:[],
				chooseItem:[],
				btnWidth: 100,
				show: false,
				kor_type:'',
				options: [
					{
						text: '删除',
						style: {
							backgroundColor: '#dd524d',
							borderRadius: '20rpx',
							textAlign: 'center',
							'margin-left':'5px',
						}
					}
				]
			}
		},
		onLoad(data) {
			
		},
		onShow() {
			var style =  uni.getStorageSync('style')
			style = JSON.parse(style)
			this.style = style
			this.kor_type = uni.getStorageSync('kor_type')?uni.getStorageSync('kor_type'):''
			if(this.$refs.paging){
				this.$refs.paging.reload()	
			}
		},
		methods: {
			open(index) {
				this.dataList[index].show = true;
				this.dataList.map((val, idx) => {
					if(index != idx) this.dataList[idx].show = false;
				})
			},
			queryList(pageNo, pageSize) {
				// 此处请求仅为演示，请替换为自己项目中的请求
				this.$wqzApi.UserAddress_list({page:pageNo , limit:pageSize , name:this.name}).then(res=>{
					this.$refs.paging.complete(res.data.list);
				})
			},
			search_submit(){
				this.queryList(1 , 20)
			},
			navTo(url){
				uni.navigateTo({
					url:url
				})
			},
			del(id){
				var data = {
					id:id
				}
				uni.showModal({
					title: '提示',//标题
					content: "确认删除收货地址",//提示内容可以加入\r\n进行换行
					showCancel: true,//是否显示取消按钮，默认为true
					success: res => {
						if (res.confirm) { //点击确定之后执行的代码
						// /kor_index/UserAddress/del
						if(this.kor_type=='kor'){
							this.$wqzApi.UserAddress_del(data).then(res=>{
								uni.showToast({
									title:"操作成功",
									icon:'none'
								})
								this.$refs.paging.reload()	
							})
						}else{
							this.$wqzApi.kor_UserAddress_del(data).then(res=>{
								uni.showToast({
									title:"操作成功",
									icon:'none'
								})
								this.$refs.paging.reload()	
							})
							
						}
							
						} else if (res.cancel) { //点击取消之后执行的代码
						}
					},
				});
				
			},
			
		}
	}
</script>

<style lang="scss" >
	@import url(./address.scss);
</style>
